package traveler.controllers;

import traveler.activities.CourseAddActivity;
import traveler.activities.SocialActivity;
import traveler.tools.ExtendedAlertDialog;
import traveler.tools.Tools;
import android.app.Activity;
import android.content.DialogInterface;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;

public class SocialController extends BaseController implements View.OnClickListener,
		OnItemClickListener, DialogInterface.OnClickListener {

	public SocialController(Activity activity)
	{
		super(activity);
	}

	public void onClick(View v) {
		Log.i("SocialController", "OnClick - START ");

		switch (v.getId()) {
		case 1:

			break;
		case 2:

			break;
		}

		Log.i("SocialController", "OnClick - END ");
	}
	
	public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
		Log.i("SocialController", "OnItemClick - START ");
		
		SocialActivity activity = (SocialActivity)_activity;
		
		Toast.makeText(activity.getBaseContext(), "" + position,
				Toast.LENGTH_SHORT).show();
		activity.get_name().setText("name " + position);
		activity.get_description().setText("description " + position);
		activity.get_step().setText("" + position);
		activity.get_rate().setRating(position);
		Log.i("SocialController", "OnItemClick - END ");
	}

	public void onClick(DialogInterface dialog, int which) {
		Log.d("SocialController::onClick(d,w)", "START");

		//ExtendedAlertDialog ead = null;
		//ExtendedAlertDialog ead = (ExtendedAlertDialog) dialog;

		switch (Tools.getInstance()
				.classNameToInt(dialog.getClass().toString())) {
		default:
			Log.d("SocialController::onClick(d,w)", "OTHER DIALOG");
			switch (which) {
			case DialogInterface.BUTTON_POSITIVE:
				Log.d("SocialController::onClick(d,w)", "DialogInterface.BUTTON_POSITIVE");
				SocialActivity activity = (SocialActivity)_activity;
	        	activity.addAction();
				break;

			case DialogInterface.BUTTON_NEGATIVE:
				Log.d("SocialController::onClick(d,w)", "DialogInterface.BUTTON_NEGATIVE");
				break;

			default:
				Log.e("SocialController::onClick(d,w)", "UNMANAGED BUTTON");
				break;
			}

			dialog.cancel();
			break;
		}

		Log.d("SocialController::onClick(d,w)", "END");

	}
	
}